#include "ShowWidget.h"
#include "ui_ShowWidget.h"

ShowWidget::ShowWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ShowWidget)
{
    ui->setupUi(this);
}

ShowWidget::~ShowWidget()
{
    delete ui;
}

void ShowWidget::on_pushButton_clicked()
{
    xPlugin::InterfaceManager interfaceManager;
    QJsonObject test_obj;
    test_obj["slave_id"] = static_cast<int>(ui->spinBox_DeviceID->value());
    test_obj["pos"] = static_cast<int>(ui->spinBox_TagetPos->value());

    QJsonObject test_root;
    test_root["test"] = test_obj;

    QJsonObject root;
    root["ElectricClawPlugin"] = test_root;
    ui->textEdit_2->setText(QJsonDocument(root).toJson());

    QJsonArray resJsonArray;
    resJsonArray = interfaceManager.commandCustomData(this, root);

//    resJsonArray = interfaceManager.commandCustomData(this, "ElectricClawPlugin", "test", QJsonDocument(test_obj).toJson());
    ui->textEdit->setText(QJsonDocument(resJsonArray).toJson());
}
